﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvEditing";
                settings.KeyFieldName = "FTaskID";
                settings.CallbackRouteValues = new { Controller = "TaskCheck", Action = "TaskCheckPartial" };
                settings.Width =System.Web.UI.WebControls.Unit.Percentage(96);

                settings.Columns.Add(column =>
                {
                    column.Caption = "操作";

                    column.SetDataItemTemplateContent(c =>
                    {
                        Html.DevExpress().HyperLink(s => { s.Name = "linkEdit" + c.VisibleIndex; s.Properties.Text = "审批"; s.ToolTip = "审批"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_Edit.png"); s.Properties.ClientSideEvents.Click = "function(){TaskEdit('" + DataBinder.Eval(c.DataItem, "FTaskID") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                    });
                    column.Settings.AllowDragDrop = DefaultBoolean.False;
                    column.Settings.AllowSort = DefaultBoolean.False;
                    column.Width = 70;
                });
                settings.Columns.Add("FTaskClassName", "类型");
                settings.Columns.Add(column=>
                    {
                        column.Caption = "文件编号（督查事项)";
                        column.FieldName = "FContent";
                        column.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left;
                    });

                settings.Columns.Add("FDeptName", "责任科室");
                settings.Columns.Add("FScore", "分值");
                settings.Columns.Add("FInsDateStr", "登记时间");
                settings.Columns.Add("FEndDateStr", "超期时间");
                //settings.Columns.Add(column =>
                //{
                //    column.Caption = "超期时间";

                //    column.SetDataItemTemplateContent(c =>
                //    {
                //        if (DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")) > DateTime.Parse(DataBinder.Eval(c.DataItem, "FEndDateStr").ToString()))
                //        {
                //            ViewContext.Writer.Write(DataBinder.Eval(c.DataItem, "FEndDateStr") + " <font color=red>已超时</font> ");
                //        }
                //        else
                //        {
                //            ViewContext.Writer.Write(DataBinder.Eval(c.DataItem, "FEndDateStr") + "");
                //        }
                //    });
                //    column.Settings.AllowDragDrop = DefaultBoolean.False;
                //    column.Settings.AllowSort = DefaultBoolean.False;
                //    column.Width = 70;
                //});
                settings.Columns.Add("FStatusStr", "完成情况");

                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;


                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                
                //settings.CommandColumn.Visible = true;
                //settings.CommandColumn.ShowSelectCheckbox = true;
                //settings.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(5);

                settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
                settings.SettingsPager.FirstPageButton.Visible = true;
                settings.SettingsPager.LastPageButton.Visible = true;
                settings.SettingsPager.PageSize = ElingOA6_Admin_DSJCJ.Common.GlobalConstant.CONSTRING_PAGESIZE;
                settings.SettingsPager.AlwaysShowPager = true;
                                
                
                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };

                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };                                       
                
                
            }).Bind(Model).GetHtml()



